#include "Ebene.h"
//------------------------------------------------------------------------
// Kon-/Destruktoren
//------------------------------------------------------------------------
Ebene::Ebene(IrrlichtDevice * const dev)
	: Entity(dev)
{
	this->init();
}
//------------------------------------------------------------------------
Ebene::~Ebene(void)
{
	this->exit();
}
//------------------------------------------------------------------------
// Methoden
//------------------------------------------------------------------------
void Ebene::init()
{
	this->m_cubes = this->m_sceneMgr->addDummyTransformationSceneNode();
	this->m_cubes->setName("Ebene aus Wuerfel");

	IMeshSceneNode * cube = this->m_sceneMgr->addCubeSceneNode(3.0f, this->m_cubes);
	cube->setPosition(vector3df(-1.5f, 0.0f, -1.5f));
	cube->setScale(vector3df(Global::Konstanten::gc_Rastereinheit, 10.0f, Global::Konstanten::gc_Rastereinheit));
	cube->setMaterialFlag(EMF_LIGHTING, false);
	cube->setMaterialTexture(0, this->m_driver->getTexture("media/models/fireball.bmp"));
	this->m_plane = cube;

	auto selector = this->m_sceneMgr->createTriangleSelector(cube->getMesh(), cube);
	cube->setTriangleSelector(selector);
}
//------------------------------------------------------------------------
void Ebene::exit()
{
	//this->m_cubes->drop();
}
//------------------------------------------------------------------------
ITriangleSelector* Ebene::getCollisionStuff() const
{
	auto selector = this->m_plane->getTriangleSelector();
	
	THROW_IF_ERROR(selector, "Collision TriangleSelector not yet set.");
	
	return selector;
}
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
